package visitor;
import arbori.*;
import operatori.*;
import functii.*;

public class ToStringVisitor extends Visitor{
        private String s;
        
        public ToStringVisitor() {
			this.s ="";
		}
	
	public String getS() {
			return s;
		}

		public void setS(String s) {
			this.s = s;
		}

	public ToStringVisitor(String s) {
			this.s = s;
		}

	
	public void visitare(Operator o) {
		if(o.getFStang()!=null&&o.getFDrept()!=null)
		{
		visit(o.getFStang());
		String s1=this.s;
		visit (o.getFDrept());
		 String s2=this.s;
		 s=o.concatTermeni (s1,s2);
		}
		
	}
	
	public void visit(Plus p) {
		visitare(p);
		
	}
	@Override
	public void visit(Minus m) {
		visitare(m);		
	}

	@Override
	public void visit(Cat m) {
		visitare(m);
		
	}

	@Override
	public void visit(Produs p) {
		visitare(p);
		
	}

	@Override
	public void visit(Necunoscuta n) {
		this.s="x";
		
	}

	@Override
	public void visit(Constanta c) {
		this.s=Double.toString (c.getCt());
		
	}

	@Override
	public void visit(Sin s) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void visit(Cos c) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void visit(Nod n) {
		// TODO Auto-generated method stub
		
	}

}
